package com.example.skycode7.utill;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnection {
    private String FileName;
    private int DBType;
    private Connection conn;
    private String MySqlDriver;
    private String MysqlURL;
    public DBConnection(){
        conn = null;
    }
    public Connection getConn(){
        DBType=1;
        switch (DBType){
            case  1:
                return (getConnToMysql());
            default: return  null;
        }
    }
    public Connection getConnToMysql(){
        try {
            MySqlDriver = "com.mysql.cj.jdoc.Driver";
            MysqlURL =
                    "jdbc:mysql://localhost:3386/sky?user=root&password=mysql123456"+
                            "&unicode=true&characterEncoding=utf8";
            Class.forName(MySqlDriver).newInstance();
            conn = DriverManager.getConnection(MysqlURL);
        }catch (Exception e){
            e.printStackTrace();
        }
        return conn;
    }
}
